/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
function sendArtical() {
    var statusLength = $("#status").val().length;
    if (statusLength < 500 && statusLength > 0) {
        $.ajax({
            url: "/SocialNetwork/PostArt",
            type: 'POST',
            data: {
                status: $("#status").val(),
            },
            success: (function(data) {
                $.fancybox.close();
                $("#postHolder").prepend(data);
                $("#status").html("");
            }),
            beforeSend: function() {
                $(".fancybox").click();
            }
        });
    } else if(statusLength <= 0 ) {
         $("#inlinealert").html("<h3 style=\"color: tomato\">Your status empty</h3>");
         $(".fancyboxalert").click();
    }else if (statusLength > 500 ){
         $("#inlinealert").html("<h3 style=\"color: tomato\">Your status too long , only 500 characters</h3>");
         $(".fancyboxalert").click();
    } 
}

function SendComment(id) {
    var idInput = "#cmt"+id;
    var idComment = "#commentHolder"+ id;
    var commentLength = $(idInput).val().length;
    if (commentLength < 500 && commentLength > 0) {
        $.ajax({
            url: "/SocialNetwork/PostComment",
            type: 'POST',
            data: {
                postId : id,
                comment: $(idInput).val()
            },
            success: (function(data) {
                $.fancybox.close();
                $(idComment).prepend(data);
                $(idInput).html("");
            }),
            beforeSend: function() {
                $(".fancybox").click();
            }
        });
    } else if(commentLength <= 0 ) {
         $("#inlinealert").html("<h3 style=\"color: tomato\">Your comment empty</h3>");
         $(".fancyboxalert").click();
    }else if (commentLength > 500 ){
         $("#inlinealert").html("<h3 style=\"color: tomato\">Your comment too long , only 500 characters</h3>");
         $(".fancyboxalert").click();
    }        
}

